package com.zdb.Controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/chat")
public class ChatController {
    private final ChatClient chatClient;
    public ChatController(ChatClient.Builder clientBuilder) {
        this.chatClient = clientBuilder.build();
    }

    @Resource
    public ToolCallbackProvider toolCallbackProvider;
    @GetMapping("/mcp")
    public String chat(@RequestParam("message") String message){
        return chatClient.prompt()
                .user(message)
                .tools(toolCallbackProvider.getToolCallbacks())

                .call()
                .content();
    }
}
